package org.hry.netty.time;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;

import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

public class TimeNettyServerHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        while (true) {
            TimeUnit.SECONDS.sleep(1);
            ctx.channel().writeAndFlush(LocalDateTime.now()+"\n");
        }
    }
}
